/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.base.entity.cars;

import com.jeesite.common.collect.ListUtils;
import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;
import com.jeesite.common.utils.excel.annotation.ExcelField;
import com.jeesite.common.utils.excel.annotation.ExcelFields;
import com.jeesite.modules.sys.entity.User;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;

/**
 * 车辆档案Entity
 * @author shengbin
 * @version 2021-03-01
 */
@Table(name="t_car", alias="a", columns={
		@Column(name="car_name", attrName="carName", label="显示名称", queryType=QueryType.LIKE),
		@Column(name="car_id", attrName="carId", label="车辆编号", isPK=true, queryType=QueryType.LIKE),
		@Column(name="brand", attrName="brand", label="品牌"),
		@Column(name="energy_type", attrName="energyType", label="能源类型"),
		@Column(name="model", attrName="model", label="车型"),
		@Column(name="year", attrName="year", label="年款"),
		@Column(name="english_name", attrName="englishName", label="英文名称", queryType=QueryType.LIKE),
		@Column(name="area", attrName="area", label="区域"),
		@Column(name="remarks", attrName="remarks", label="备注信息", isQuery=false),
		@Column(name="currency", attrName="currency", label="币种"),
		@Column(name="reference_price", attrName="referencePrice", label="参考单价", isQuery=false),
		@Column(name="basic_configuration", attrName="basicConfiguration", label="基本配置", isQuery=false),
		@Column(name="create_by", attrName="createBy", label="创建者", isUpdate=false),
		@Column(name="create_date", attrName="createDate", label="创建时间", isUpdate=false),
		@Column(name="update_by", attrName="updateBy", label="更新者", isQuery=false),
		@Column(name="update_date", attrName="updateDate", label="更新时间", isQuery=false),
	},joinTable = {
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = User.class, attrName = "createByUser", alias = "createby",
                on = "createby.user_code = a.create_by", columns = {
                @Column(name = "user_code", label = "用户编码", isPK = true),
                @Column(name = "user_name", label = "用户名称", isQuery = false),
        }),
        @JoinTable(type = JoinTable.Type.LEFT_JOIN, entity = User.class, attrName = "updateByUser", alias = "updateby",
                on = "updateby.user_code = a.update_by", columns = {
                @Column(name = "user_code", label = "用户编码", isPK = true),
                @Column(name = "user_name", label = "用户名称", isQuery = false),
        }),
}, orderBy="a.update_date DESC"
)
public class Tcar extends DataEntity<Tcar> {
	@Valid
	@ExcelFields({
			@ExcelField(title="车辆编号", attrName="carId", align= ExcelField.Align.CENTER, sort=10),
			@ExcelField(title="显示名称", attrName="carName", align = ExcelField.Align.CENTER, sort=20)
			})
	private static final long serialVersionUID = 1L;
	private String carName;		// 显示名称
	private String carId;		// 车辆编号
	private String brand;		// 品牌
	private String energyType;		// 能源类型
	private String model;		// 车型
	private String year;		// 年款
	private String englishName;		// 英文名称
	private String area;		// 区域
	private String currency;		// 币种
	private Double referencePrice;		// 参考单价
	private String basicConfiguration;		// 基本配置
	private List<TcarConfiguration> tcarConfigurationList = ListUtils.newArrayList();		// 子表列表
    private User createByUser;
    private User updateByUser;


	public Tcar() {
		this(null);
	}

	public Tcar(String id){
		super(id);
	}

	@Length(min=0, max=100, message="显示名称长度不能超过 100 个字符")
	public String getCarName() {
		return carName;
	}

	public void setCarName(String carName) {
		this.carName = carName;
	}
	
	public String getCarId() {
		return carId;
	}

	public void setCarId(String carId) {
		this.carId = carId;
	}
	
	@NotBlank(message="品牌不能为空")
	@Length(min=0, max=2, message="品牌长度不能超过 2 个字符")
	public String getBrand() {
		return brand;
	}

	public void setBrand(String brand) {
		this.brand = brand;
	}
	
	@NotBlank(message="能源类型不能为空")
	@Length(min=0, max=2, message="能源类型长度不能超过 2 个字符")
	public String getEnergyType() {
		return energyType;
	}

	public void setEnergyType(String energyType) {
		this.energyType = energyType;
	}
	
	@NotBlank(message="车型不能为空")
	@Length(min=0, max=100, message="车型长度不能超过 100 个字符")
	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		this.model = model;
	}
	
	@NotBlank(message="年款不能为空")
	@Length(min=0, max=2, message="年款长度不能超过 2 个字符")
	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}
	
	@NotBlank(message="英文名称不能为空")
	@Length(min=0, max=100, message="英文名称长度不能超过 100 个字符")
	public String getEnglishName() {
		return englishName;
	}

	public void setEnglishName(String englishName) {
		this.englishName = englishName;
	}
	
	@NotBlank(message="区域不能为空")
	@Length(min=0, max=64, message="区域长度不能超过 64 个字符")
	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}
	
	@NotBlank(message="币种不能为空")
	@Length(min=0, max=2, message="币种长度不能超过 2 个字符")
	public String getCurrency() {
		return currency;
	}

	public void setCurrency(String currency) {
		this.currency = currency;
	}
	
	public Double getReferencePrice() {
		return referencePrice;
	}

	public void setReferencePrice(Double referencePrice) {
		this.referencePrice = referencePrice;
	}
	
	@Length(min=0, max=500, message="基本配置长度不能超过 500 个字符")
	public String getBasicConfiguration() {
		return basicConfiguration;
	}

	public void setBasicConfiguration(String basicConfiguration) {
		this.basicConfiguration = basicConfiguration;
	}

	public Date getCreateDate_gte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.GTE);
	}

	public void setCreateDate_gte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.GTE, createDate);
	}

	public Date getCreateDate_lte() {
		return sqlMap.getWhere().getValue("create_date", QueryType.LTE);
	}

	public void setCreateDate_lte(Date createDate) {
		sqlMap.getWhere().and("create_date", QueryType.LTE, createDate);
	}

	public List<TcarConfiguration> getTcarConfigurationList() {
		return tcarConfigurationList;
	}

	public void setTcarConfigurationList(List<TcarConfiguration> tcarConfigurationList) {
		this.tcarConfigurationList = tcarConfigurationList;
	}

    public User getCreateByUser() {
        return createByUser;
    }

    public void setCreateByUser(User createByUser) {
        this.createByUser = createByUser;
    }

    public User getUpdateByUser() {
        return updateByUser;
    }

    public void setUpdateByUser(User updateByUser) {
        this.updateByUser = updateByUser;
    }
}